import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayChannelVo, PayChannelForm, PayChannelQuery } from '@/api/pay/channel/types';

/**
 * 查询支付通道列表
 * @param query
 * @returns {*}
 */

export const listPayChannel = (query?: PayChannelQuery): AxiosPromise<PayChannelVo[]> => {
  return request({
    url: '/lawyer/payChannel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询支付通道详细
 * @param id
 */
export const getPayChannel = (id: string | number): AxiosPromise<PayChannelVo> => {
  return request({
    url: '/lawyer/payChannel/' + id,
    method: 'get'
  });
};

/**
 * 新增支付通道
 * @param data
 */
export const addPayChannel = (data: PayChannelForm) => {
  return request({
    url: '/lawyer/payChannel/savePayChannel',
    method: 'post',
    data: data
  });
};

/**
 * 修改支付通道
 * @param data
 */
export const updatePayChannel = (data: PayChannelForm) => {
  return request({
    url: '/lawyer/payChannel/updatePayChannel',
    method: 'post',
    data: data
  });
};

/**
 * 删除支付通道
 * @param id
 */
export const delPayChannel = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/payChannel/removePayChannel/' + id,
    method: 'delete'
  });
};

export const activePayChannel = (id: string | number) => {
  const data = {
    id
  };
  return request({
    url: '/lawyer/payChannel/activePayChannel',
    method: 'post',
    data: data
  });
};

export const inactivePayChannel = (id: string | number) => {
  const data = {
    id
  };
  return request({
    url: '/lawyer/payChannel/inactivePayChannel',
    method: 'post',
    data: data
  });
};

